//
//  VVEmoticonButton.swift
//  Weibo
//
//  Created by 王惠平 on 2017/4/8.
//  Copyright © 2017年 Will Wang. All rights reserved.
//

import UIKit
//自定义表情按钮
class VVEmoticonButton: UIButton {

    //关联的表情模型
    var emoticon: VVEmoticon? {
        
        didSet {
            
            guard let currentEmoticon = emoticon else {
                
                return
            }
            self.isHidden = false
            
            if currentEmoticon.type == "0" {
                
                //图片表情
                self.setImage(UIImage(named:currentEmoticon.path!), for: .normal)
                self.setTitle(nil, for: .normal)
                
            } else {
                
                //emoji表情
                let emoji = (currentEmoticon.code! as NSString).emoji()
                
                self.setTitle(emoji, for: .normal)
                self.setImage(nil, for: .normal)
                
            }
        }
    }

}
